Option Strict Off
Option Explicit On
Friend Class GenObjArr
	
	Private mvarArray() As Object
	Private mlngCount As Integer
	Private mlngIncrement As Integer
	
	'UPGRADE_NOTE: Class_Initialize was upgraded to Class_Initialize_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Private Sub Class_Initialize_Renamed()
		ReDim mvarArray(4) 'start with 5 elements
		mlngCount = 0
		mlngIncrement = 5
	End Sub
	Public Sub New()
		MyBase.New()
		Class_Initialize_Renamed()
	End Sub
	
	Public Function Item(ByRef ZeroBasedIndex As Integer) As Object
		If ZeroBasedIndex < 0 Or ZeroBasedIndex >= mlngCount Then
			Err.Raise(1, "Item(" & CStr(ZeroBasedIndex) & ")", "Item index out of range")
		End If
		'UPGRADE_WARNING: IsObject has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If IsReference(mvarArray(ZeroBasedIndex)) Then
			Item = mvarArray(ZeroBasedIndex)
		Else
			'UPGRADE_WARNING: Couldn't resolve default property of object mvarArray(ZeroBasedIndex). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			Item = mvarArray(ZeroBasedIndex)
		End If
	End Function
	
	Public ReadOnly Property Count() As Integer
		Get
			Count = mlngCount
		End Get
	End Property
	Public Property zAutoIncrementUnits() As Integer
		Get
			zAutoIncrementUnits = mlngIncrement
		End Get
		Set(ByVal Value As Integer)
			If mlngIncrement >= 1 Then
				mlngIncrement = Value
			End If
		End Set
	End Property
	
	
	Public Property zArraySize() As Integer
		Get
			zArraySize = UBound(mvarArray) + 1
		End Get
		Set(ByVal Value As Integer)
			If Value > UBound(mvarArray) + 1 Then
				ReDim Preserve mvarArray(Value - 1)
			End If
		End Set
	End Property
	
	Public Sub Add(ByRef NewItem As Object)
		If Not RoomAvailable Then
			AddRoom()
		End If
		'UPGRADE_WARNING: IsObject has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If IsReference(NewItem) Then
			mvarArray(mlngCount) = NewItem
		Else
			'UPGRADE_WARNING: Couldn't resolve default property of object NewItem. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object mvarArray(mlngCount). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			mvarArray(mlngCount) = NewItem
		End If
		mlngCount = mlngCount + 1
	End Sub
	
	Private Function RoomAvailable() As Boolean
		If mlngCount < UBound(mvarArray) Then
			RoomAvailable = True
		Else
			RoomAvailable = False
		End If
	End Function
	
	Private Sub AddRoom()
		ReDim Preserve mvarArray(UBound(mvarArray) + mlngIncrement)
	End Sub
	
	'UPGRADE_NOTE: InputString was upgraded to InputString_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Sub GenerateNewFromString(ByRef InputString_Renamed As String, ByRef ParseCharacter As String, Optional ByRef SuperTrimEachElement As Boolean = True, Optional ByRef AddBlankElements As Boolean = True)
		
        Dim strTemp As String
		Dim aryInputString() As String
		Dim lngIndex As Integer
		If InStr(1, InputString_Renamed, ParseCharacter, CompareMethod.Binary) = 0 Then
			'RESET THE ARRAY TO 1 ELEMENT
			ReDim mvarArray(0)
			mlngCount = 0
			If AddBlankElements = True Then
				Add(InputString_Renamed)
			Else
				If Len(InputString_Renamed) > 0 Then
					Add(InputString_Renamed)
				End If
			End If
		Else
			aryInputString = Split(InputString_Renamed, ParseCharacter)
			
			'RESET ARRAY AND PRESIZE TO FIT ENTIRE ARRAY
			ReDim mvarArray(UBound(aryInputString))
			mlngCount = 0
			
			For lngIndex = 0 To UBound(aryInputString)
				strTemp = aryInputString(lngIndex)
				If SuperTrimEachElement = True Then
					strTemp = MyTrim(strTemp)
				End If
				If AddBlankElements = True Then
					Add(strTemp)
				Else
					If Len(strTemp) > 0 Then
						Add(strTemp)
					End If
				End If
			Next 
		End If
	End Sub
End Class